/*

BlackRabbit - OpenSource IDE.
@author Edward Sarkisyan (edward.sarkisyan@gmail.com)
Use LGPL (http://www.gnu.org/copyleft/lesser.html)

*/

#include "gadgetwindowwidget.h"
#include "ui_gadgetwindowwidget.h"

GadgetWindowWidget::GadgetWindowWidget(QWidget *parent) :
    QWidget(parent),
    m_ui(new Ui::GadgetWindowWidget)
{
    m_ui->setupUi(this);
    m_ui->controlsFrame->hide();
}

GadgetWindowWidget::~GadgetWindowWidget()
{
    delete m_ui;
}

void GadgetWindowWidget::changeEvent(QEvent *e)
{
    QWidget::changeEvent(e);
    switch (e->type()) {
    case QEvent::LanguageChange:
        m_ui->retranslateUi(this);
        break;
    default:
        break;
    }
}

void GadgetWindowWidget::setWindowWidget(QWidget* widget)
{
    if(widget!=0)
    {
        m_ui->pluginWidgetContainerLayout->insertWidget(0,widget);
        this->setSizePolicy(widget->sizePolicy());
    }
}

void GadgetWindowWidget::setTitle(QString title)
{
    m_ui->titleLabel->setText(title);
}

void GadgetWindowWidget::setIcon(QPixmap icon)
{
    m_ui->pluginIconLabel->setPixmap(icon);
}

void GadgetWindowWidget::on_showMoreBttn_clicked()
{
    m_ui->controlsFrame->setVisible(!m_ui->controlsFrame->isVisible());
}

QPushButton* GadgetWindowWidget::settingsButton()
{
    return m_ui->settingsBttn;
}
